<!DOCTYPE html>
<html lang="en">
<head>
    
    <meta charset="utf-8">
    <title>my-list/src/List.vue - Documentation</title>
    
    
    <script src="scripts/prettify/prettify.js"></script>
    <script src="scripts/prettify/lang-css.js"></script>
    <link type="text/css" rel="stylesheet" href="styles/prettify.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
    <script src="scripts/nav.js" defer></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
  <div class="navicon"></div>
</label>

<label for="nav-trigger" class="overlay"></label>

<nav >
    
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Outline.html">Outline</a></li><li><a href="Tag.html">Tag</a></li><li><a href="TagCanvas.html">TagCanvas</a></li></ul><h3>Modules</h3><ul><li><a href="module-$ui_components_my-affix.html">$ui/components/my-affix</a></li><li><a href="module-$ui_components_my-anchor.html">$ui/components/my-anchor</a></li><li><a href="module-$ui_components_my-autocomplete.html">$ui/components/my-autocomplete</a></li><li><a href="module-$ui_components_my-avatar.html">$ui/components/my-avatar</a></li><li><a href="module-$ui_components_my-avatars.html">$ui/components/my-avatars</a></li><li><a href="module-$ui_components_my-back-top.html">$ui/components/my-back-top</a></li><li><a href="module-$ui_components_my-capture.html">$ui/components/my-capture</a><ul class='methods'><li data-type='method'><a href="module-$ui_components_my-capture.html#~_renderImg">_renderImg</a></li></ul></li><li><a href="module-$ui_components_my-card-list.html">$ui/components/my-card-list</a><ul class='methods'><li data-type='method'><a href="module-$ui_components_my-card-list.html#~refresh">refresh</a></li></ul></li><li><a href="module-$ui_components_my-cascader.html">$ui/components/my-cascader</a></li><li><a href="module-$ui_components_my-checkbox.html">$ui/components/my-checkbox</a></li><li><a href="module-$ui_components_my-clipboard.html">$ui/components/my-clipboard</a><ul class='methods'><li data-type='method'><a href="module-$ui_components_my-clipboard.html#~copy">copy</a></li></ul></li><li><a href="module-$ui_components_my-color-picker.html">$ui/components/my-color-picker</a></li><li><a href="module-$ui_components_my-contextmenu.html">$ui/components/my-contextmenu</a></li><li><a href="module-$ui_components_my-corner-mark.html">$ui/components/my-corner-mark</a></li><li><a href="module-$ui_components_my-crud.html">$ui/components/my-crud</a><ul class='methods'><li data-type='method'><a href="module-$ui_components_my-crud.html#~openAddDialog">openAddDialog</a></li><li data-type='method'><a href="module-$ui_components_my-crud.html#~refresh">refresh</a></li><li data-type='method'><a href="module-$ui_components_my-crud.html#~reload">reload</a></li></ul></li><li><a href="module-$ui_components_my-date.html">$ui/components/my-date</a></li><li><a href="module-$ui_components_my-date-picker.html">$ui/components/my-date-picker</a></li><li><a href="module-$ui_components_my-detail.html">$ui/components/my-detail</a></li><li><a href="module-$ui_components_my-detail-item.html">$ui/components/my-detail-item</a></li><li><a href="module-$ui_components_my-dialog.html">$ui/components/my-dialog</a></li><li><a href="module-$ui_components_my-drag.html">$ui/components/my-drag</a><ul class='methods'><li data-type='method'><a href="module-$ui_components_my-drag.html#~getRelativeEl">getRelativeEl</a></li></ul></li><li><a href="module-$ui_components_my-drop.html">$ui/components/my-drop</a></li><li><a href="module-$ui_components_my-edit-tags.html">$ui/components/my-edit-tags</a></li><li><a href="module-$ui_components_my-editor.html">$ui/components/my-editor</a></li><li><a href="module-$ui_components_my-empty.html">$ui/components/my-empty</a></li><li><a href="module-$ui_components_my-filter.html">$ui/components/my-filter</a></li><li><a href="module-$ui_components_my-fixed.html">$ui/components/my-fixed</a><ul class='methods'><li data-type='method'><a href="module-$ui_components_my-fixed.html#~resize">resize</a></li></ul></li><li><a href="module-$ui_components_my-flex.html">$ui/components/my-flex</a></li><li><a href="module-$ui_components_my-flex-item.html">$ui/components/my-flex-item</a></li><li><a href="module-$ui_components_my-flip.html">$ui/components/my-flip</a></li><li><a href="module-$ui_components_my-float.html">$ui/components/my-float</a></li><li><a href="module-$ui_components_my-float-item.html">$ui/components/my-float-item</a></li><li><a href="module-$ui_components_my-form.html">$ui/components/my-form</a><ul class='methods'><li data-type='method'><a href="module-$ui_components_my-form.html#~reset">reset</a></li><li data-type='method'><a href="module-$ui_components_my-form.html#~submit">submit</a></li></ul></li><li><a href="module-$ui_components_my-form_src_Base.html">$ui/components/my-form/src/Base</a></li><li><a href="module-$ui_components_my-form_src_common_TagInput.html">$ui/components/my-form/src/common/TagInput</a></li><li><a href="module-$ui_components_my-form_src_common_TagSelect.html">$ui/components/my-form/src/common/TagSelect</a></li><li><a href="module-$ui_components_my-form_src_common_TreeSelect.html">$ui/components/my-form/src/common/TreeSelect</a></li><li><a href="module-$ui_components_my-grid-layout.html">$ui/components/my-grid-layout</a></li><li><a href="module-$ui_components_my-header.html">$ui/components/my-header</a></li><li><a href="module-$ui_components_my-highlight.html">$ui/components/my-highlight</a></li><li><a href="module-$ui_components_my-icon.html">$ui/components/my-icon</a></li><li><a href="module-$ui_components_my-img-text.html">$ui/components/my-img-text</a></li><li><a href="module-$ui_components_my-input.html">$ui/components/my-input</a></li><li><a href="module-$ui_components_my-input-number.html">$ui/components/my-input-number</a></li><li><a href="module-$ui_components_my-layout.html">$ui/components/my-layout</a></li><li><a href="module-$ui_components_my-lazy.html">$ui/components/my-lazy</a></li><li><a href="module-$ui_components_my-list.html">$ui/components/my-list</a><ul class='methods'><li data-type='method'><a href="module-$ui_components_my-list.html#~load">load</a></li><li data-type='method'><a href="module-$ui_components_my-list.html#~refresh">refresh</a></li><li data-type='method'><a href="module-$ui_components_my-list.html#~reset">reset</a></li><li data-type='method'><a href="module-$ui_components_my-list.html#~scrollTop">scrollTop</a></li></ul></li><li><a href="module-$ui_components_my-marquee.html">$ui/components/my-marquee</a><ul class='methods'><li data-type='method'><a href="module-$ui_components_my-marquee.html#~pause">pause</a></li><li data-type='method'><a href="module-$ui_components_my-marquee.html#~start">start</a></li><li data-type='method'><a href="module-$ui_components_my-marquee.html#~stop">stop</a></li></ul></li><li><a href="module-$ui_components_my-menu.html">$ui/components/my-menu</a></li><li><a href="module-$ui_components_my-navbar.html">$ui/components/my-navbar</a></li><li><a href="module-$ui_components_my-navbar-FullScreenAction.html">$ui/components/my-navbar-FullScreenAction</a></li><li><a href="module-$ui_components_my-navbar-IconAction.html">$ui/components/my-navbar-IconAction</a></li><li><a href="module-$ui_components_my-navbar-UserAction.html">$ui/components/my-navbar-UserAction</a></li><li><a href="module-$ui_components_my-number.html">$ui/components/my-number</a></li><li><a href="module-$ui_components_my-panel.html">$ui/components/my-panel</a></li><li><a href="module-$ui_components_my-paragraph.html">$ui/components/my-paragraph</a></li><li><a href="module-$ui_components_my-pro.html">$ui/components/my-pro</a><ul class='methods'><li data-type='method'><a href="module-$ui_components_my-pro.html#~addTab">addTab</a></li><li data-type='method'><a href="module-$ui_components_my-pro.html#~closeTabs">closeTabs</a></li><li data-type='method'><a href="module-$ui_components_my-pro.html#~setTab">setTab</a></li></ul></li><li><a href="module-$ui_components_my-promise.html">$ui/components/my-promise</a></li><li><a href="module-$ui_components_my-radio.html">$ui/components/my-radio</a></li><li><a href="module-$ui_components_my-range.html">$ui/components/my-range</a></li><li><a href="module-$ui_components_my-rate.html">$ui/components/my-rate</a></li><li><a href="module-$ui_components_my-resize.html">$ui/components/my-resize</a></li><li><a href="module-$ui_components_my-result.html">$ui/components/my-result</a></li><li><a href="module-$ui_components_my-revolve.html">$ui/components/my-revolve</a><ul class='methods'><li data-type='method'><a href="module-$ui_components_my-revolve.html#~next">next</a></li><li data-type='method'><a href="module-$ui_components_my-revolve.html#~prev">prev</a></li><li data-type='method'><a href="module-$ui_components_my-revolve.html#~start">start</a></li><li data-type='method'><a href="module-$ui_components_my-revolve.html#~stop">stop</a></li></ul></li><li><a href="module-$ui_components_my-select.html">$ui/components/my-select</a></li><li><a href="module-$ui_components_my-sidebar.html">$ui/components/my-sidebar</a></li><li><a href="module-$ui_components_my-skeleton.html">$ui/components/my-skeleton</a></li><li><a href="module-$ui_components_my-slider.html">$ui/components/my-slider</a></li><li><a href="module-$ui_components_my-sortable.html">$ui/components/my-sortable</a></li><li><a href="module-$ui_components_my-spin.html">$ui/components/my-spin</a></li><li><a href="module-$ui_components_my-stat-card.html">$ui/components/my-stat-card</a></li><li><a href="module-$ui_components_my-switch.html">$ui/components/my-switch</a></li><li><a href="module-$ui_components_my-table.html">$ui/components/my-table</a><ul class='methods'><li data-type='method'><a href="module-$ui_components_my-table.html#~refresh">refresh</a></li></ul></li><li><a href="module-$ui_components_my-tag-canvas.html">$ui/components/my-tag-canvas</a></li><li><a href="module-$ui_components_my-tag-input.html">$ui/components/my-tag-input</a></li><li><a href="module-$ui_components_my-tag-select.html">$ui/components/my-tag-select</a></li><li><a href="module-$ui_components_my-text.html">$ui/components/my-text</a></li><li><a href="module-$ui_components_my-timer.html">$ui/components/my-timer</a><ul class='methods'><li data-type='method'><a href="module-$ui_components_my-timer.html#~reset">reset</a></li><li data-type='method'><a href="module-$ui_components_my-timer.html#~start">start</a></li><li data-type='method'><a href="module-$ui_components_my-timer.html#~stop">stop</a></li></ul></li><li><a href="module-$ui_components_my-title.html">$ui/components/my-title</a></li><li><a href="module-$ui_components_my-tree-select.html">$ui/components/my-tree-select</a></li><li><a href="module-$ui_components_my-typography.html">$ui/components/my-typography</a></li><li><a href="module-$ui_components_my-watermark.html">$ui/components/my-watermark</a></li><li><a href="module-$ui_components_my-wrapper.html">$ui/components/my-wrapper</a></li><li><a href="module-widgets_my-print.html">widgets/my-print</a></li></ul><h3>Events</h3><ul><li><a href="module-$ui_components_my-stat-card.html#~event:action">action</a></li><li></li><li><a href="module-$ui_components_my-form_src_common_TagInput.html#~event:add">add</a></li><li><a href="module-$ui_components_my-wrapper.html#~event:back">back</a></li><li><a href="module-$ui_components_my-dialog.html#~event:cancel">cancel</a></li><li><a href="module-$ui_components_my-typography.html#~event:change">change</a></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li><a href="module-$ui_components_my-navbar-UserAction.html#~event:click">click</a></li><li></li><li></li><li></li><li></li><li><a href="module-$ui_components_my-avatars.html#~event:click-add">click-add</a></li><li><a href="module-$ui_components_my-avatars.html#~event:click-item">click-item</a></li><li><a href="module-$ui_components_my-avatars.html#~event:click-more">click-more</a></li><li><a href="module-$ui_components_my-dialog.html#~event:close">close</a></li><li><a href="module-$ui_components_my-pro.html#~event:collapse">collapse</a></li><li><a href="module-$ui_components_my-form_src_common_TagSelect.html#~event:collapsed">collapsed</a></li><li><a href="module-$ui_components_my-navbar-UserAction.html#~event:command">command</a></li><li></li><li></li><li><a href="global.html#event:complete">complete</a></li><li></li><li><a href="module-$ui_components_my-contextmenu.html#~event:contextmenu">contextmenu</a></li><li><a href="module-$ui_components_my-typography.html#event:copy">copy</a></li><li></li><li></li><li></li><li></li><li><a href="module-$ui_components_my-drag.html#~event:drag">drag</a></li><li></li><li><a href="module-$ui_components_my-dialog.html#~event:drag-start">drag-start</a></li><li><a href="module-$ui_components_my-dialog.html#~event:drag-stop">drag-stop</a></li><li><a href="module-$ui_components_my-drop.html#~event:drop">drop</a></li><li><a href="module-$ui_components_my-typography.html#event:edited">edited</a></li><li></li><li></li><li></li><li></li><li><a href="module-$ui_components_my-typography.html#event:editing">editing</a></li><li></li><li></li><li></li><li></li><li><a href="module-$ui_components_my-drop.html#~event:enter">enter</a></li><li><a href="module-$ui_components_my-table.html#~event:error">error</a></li><li></li><li></li><li></li><li></li><li><a href="module-$ui_components_my-typography.html#event:expand">expand</a></li><li></li><li></li><li></li><li></li><li><a href="module-$ui_components_my-timer.html#~event:finish">finish</a></li><li><a href="module-$ui_components_my-dialog.html#~event:hide">hide</a></li><li></li><li><a href="module-$ui_components_my-lazy.html#~event:init">init</a></li><li><a href="module-$ui_components_my-form_src_common_TagInput.html#~event:input-change">input-change</a></li><li><a href="module-$ui_components_my-grid-layout.html#~event:layout-updated">layout-updated</a></li><li><a href="module-$ui_components_my-drop.html#~event:leave">leave</a></li><li><a href="module-$ui_components_my-wrapper.html#~event:link-click">link-click</a></li><li><a href="module-$ui_components_my-dialog.html#~event:load">load</a></li><li><a href="module-$ui_components_my-revolve.html#~event:loaded">loaded</a></li><li><a href="module-$ui_components_my-dialog.html#~event:maximize">maximize</a></li><li><a href="module-$ui_components_my-contextmenu.html#~event:mouseenter">mouseenter</a></li><li></li><li><a href="module-$ui_components_my-capture.html#~event:on-capture">on-capture</a></li><li><a href="global.html#event:on-change">on-change</a></li><li><a href="module-$ui_components_my-tag-canvas.html#~event:on-click">on-click</a></li><li><a href="module-$ui_components_my-capture.html#~event:on-output">on-output</a></li><li><a href="module-$ui_components_my-dialog.html#~event:open">open</a></li><li><a href="module-$ui_components_my-drop.html#~event:over">over</a></li><li><a href="global.html#~event:page-change">page-change</a></li><li></li><li></li><li><a href="module-$ui_components_my-revolve.html#~event:progress">progress</a></li><li><a href="module-$ui_components_my-form_src_common_TagInput.html#~event:remove">remove</a></li><li><a href="module-$ui_components_my-timer.html#~event:reset">reset</a></li><li></li><li><a href="module-$ui_components_my-resize.html#~event:resize">resize</a></li><li></li><li><a href="module-$ui_components_my-dialog.html#~event:resize-start">resize-start</a></li><li><a href="module-$ui_components_my-dialog.html#~event:resize-stop">resize-stop</a></li><li><a href="module-$ui_components_my-sidebar.html#~event:select">select</a></li><li></li><li></li><li></li><li><a href="module-$ui_components_my-dialog.html#~event:show">show</a></li><li></li><li><a href="global.html#~event:size-change">size-change</a></li><li></li><li></li><li><a href="module-$ui_components_my-timer.html#~event:start">start</a></li><li></li><li></li><li></li><li><a href="module-$ui_components_my-timer.html#~event:stop">stop</a></li><li></li><li></li><li></li><li><a href="module-$ui_components_my-form.html#~event:submit">submit</a></li><li></li><li><a href="module-$ui_components_my-table.html#~event:success">success</a></li><li></li><li></li><li><a href="module-$ui_components_my-panel.html#~event:tab-change">tab-change</a></li><li><a href="module-$ui_components_my-pro.html#~event:tab-remove">tab-remove</a></li><li><a href="module-$ui_components_my-pro.html#~event:tab-select">tab-select</a></li><li><a href="module-$ui_components_my-timer.html#~event:tick">tick</a></li><li><a href="module-$ui_components_my-form.html#~event:validate">validate</a></li><li><a href="module-widgets_my-back-top.html#event:click">click</a></li></ul><h3>Global</h3><ul><li><a href="global.html#AddShadowToImage">AddShadowToImage</a></li><li><a href="global.html#appendChildNode">appendChildNode</a></li><li><a href="global.html#createEllipsisContainer">createEllipsisContainer</a></li><li><a href="global.html#createEllipsisContentHolder">createEllipsisContentHolder</a></li><li><a href="global.html#destroyVue">destroyVue</a></li><li><a href="global.html#getData">getData</a></li><li><a href="global.html#inRange">inRange</a></li><li><a href="global.html#instanceVue">instanceVue</a></li><li><a href="global.html#props">props</a></li><li><a href="global.html#pxToNumber">pxToNumber</a></li><li><a href="global.html#removeEllipsisContainer">removeEllipsisContainer</a></li><li><a href="global.html#RoundImage">RoundImage</a></li><li><a href="global.html#scrollTop">scrollTop</a></li><li><a href="global.html#setData">setData</a></li><li><a href="global.html#styleToString">styleToString</a></li><li><a href="global.html#wrapperDecorations">wrapperDecorations</a></li></ul>
</nav>

<div id="main">
    
    <h1 class="page-title">my-list/src/List.vue</h1>
    

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>&lt;template>
  &lt;div class="my-list" :class="classes">
    &lt;!--头部-->
    &lt;div v-if="$slots.header"
         ref="header"
         class="my-list__header"
         :style="headerStyle">
      &lt;slot name="header">&lt;/slot>
    &lt;/div>

    &lt;!-- 列表内容 -->
    &lt;div ref="viewport"
         class="my-list__wrapper"
         @scroll="handleVirtualScroll"
         :class="wrapperClass"
         :style="wrapperStyle">
      &lt;!-- 内容 -->
      &lt;MySpin v-bind="spin" :fit="isFit" :loading="(isPager || isVirtual) &amp;&amp; currentLoading">

        &lt;!-- 无数据 -->
        &lt;div v-if="!list.length &amp;&amp; !errorMessage" class="my-list__empty">
          &lt;slot name="empty">
            暂无数据
          &lt;/slot>
        &lt;/div>

        &lt;div v-if="error &amp;&amp; errorMessage" class="my-list__error">
          &lt;slot name="error" :message="errorMessage">
            抱歉！发生异常错误，请稍后重试。
          &lt;/slot>
        &lt;/div>

        &lt;!-- 虚拟列表占位容器，为了撑开内容出现滚动条 -->
        &lt;div v-if="isVirtual" class="my-list__placeholder" :style="{height:`${contentHeight}px`}">&lt;/div>

        &lt;ul ref="list"
            class="my-list__content"
            v-if="list.length &amp;&amp; !errorMessage"
            v-infinite-scroll="load"
            :infinite-scroll-immediate="auto"
            :infinite-scroll-delay="scrollDelay"
            :infinite-scroll-distance="scrollDistance"
            :infinite-scroll-disabled="scrollDisabled"
            :style="contentStyle">
          &lt;li v-for="(item, index) in (isVirtual ? viewItems : list)"
              :key="`item_${index}`"
              class="my-list__item"
              :class="createItemClass(index)"
              :style="itemStyle">
            &lt;slot :item="item"
                  :index="startIndex + index"
                  :page="currentPage"
                  :pageSize="currentPageSize"
                  :total="currentTotal">
              {{item}}
            &lt;/slot>
          &lt;/li>
          &lt;li v-for="n in fixItemCount"
              :key="n"
              class="my-list__item"
              :class="createItemClass((isVirtual ? viewItems : list).length + n - 1)"
              :style="itemStyle">&lt;/li>
        &lt;/ul>

        &lt;!-- 骨架 -->
        &lt;div v-if="isScroll &amp;&amp; !isNoMore &amp;&amp; currentLoading" class="my-list__scroll-loading">
          &lt;slot name="skeleton">
            &lt;MySpin loading>&lt;/MySpin>
          &lt;/slot>
        &lt;/div>

        &lt;!-- 没有更多提示 -->
        &lt;div v-if="isScroll &amp;&amp; isNoMore &amp;&amp; currentPage>1" class="my-list__complete">
          &lt;slot name="complete">
            没有更多了
          &lt;/slot>
        &lt;/div>


      &lt;/MySpin>
    &lt;/div>

    &lt;!-- 底部 -->
    &lt;div v-if="$slots.footer"
         ref="footer"
         class="my-list__footer"
         :style="footerStyle">
      &lt;slot name="footer">&lt;/slot>
    &lt;/div>

    &lt;!-- 分页 -->
    &lt;Pagination v-if="isPager &amp;&amp; currentTotal"
                ref="pager"
                v-bind="pagerProps"
                :total="currentTotal"
                :class="pagerClass"
                @size-change="handlePageSizeChange"
                @current-change="handlePageChange">&lt;/Pagination>
  &lt;/div>

&lt;/template>

&lt;script>

  /**
   * 列表组件
   * @module $ui/components/my-list
   */

  import {Pagination} from 'element-ui'
  import {MySpin} from '$ui'

  import Style from './Style'
  import Pager from './Pager'
  import Scroll from './Scroll'
  import Virtual from './Virtual'

  /**
   * 插槽
   * @member slots
   * @property {string} default 默认作用域插槽，参数：item 列表， index 数据索引, page 当前页码，pageSize 页面大小，total 数据总数
   * @property {string} header 定义头部
   * @property {string} footer 定义底部
   * @property {string} skeleton 定义骨架加载效果，对滚动加载模式有效
   * @property {string} empty 定义无数据显示效果
   * @property {string} error 定义异常显示效果，参数error为true才有效
   * @property {string} complete 定义滚动加载到底时显示内容
   */
  export default {
    name: 'MyList',
    mixins: [Style, Pager, Scroll, Virtual],
    components: {
      Pagination,
      MySpin
    },

    /**
     * 属性参数
     * @member props
     * @property {Array} [data] 静态数据
     * @property {Function} [loader] 加载数据回调函数，参数：page 页码，pageSize 页大小，必须返回Promise，数据格式：{list, total}
     * @property {Number|Object} 显示列数，支持响应式,响应式设置对象 {xxl,xl,lg,md,sm,xs}
     * @property {boolean} [fixColumns] 修正不够一行的列， columns > 1 才有效
     * @property {boolean} [border] 显示边框
     * @property {boolean} [split] 显示分隔线
     * @property {boolean} [stripe] 斑马条纹
     * @property {boolean} [size] 尺寸, 可选 'large', 'small', 'mini', ''
     * @property {Object} [headerStyle] 头部样式
     * @property {Object} [footerStyle] 底部样式
     * @property {Object} [spin] 分页模式的加载中组件配置 {tip, size}，参考MySpin组件
     * @property {Boolean} [loading] 显示 加载中
     * @property {string} [mode=pager] 列表模式，支持页码分页、滚动分页、虚拟列表，可选值：'pager', 'scroll', 'virtual'
     * @property {number} [page=1] 初始加载页码， 从1开始
     * @property {number} [pageSize=10] 每页显示几条
     * @property {number} [total=0] 数据条数
     * @property {Object} [pagination] 分页其他配置, 如 {layout, background, small}，参考ElPagination组件
     * @property {boolean} [auto=true] 初始化完成后调用loader
     * @property {boolean} [error] 显示请求错误
     * @property {number} [scrollDelay=200] 节流时延，单位为ms, 对滚动加载模式有效
     * @property {number} [scrollDistance=0] 触发加载的距离阈值，单位为px, 对滚动加载模式有效
     * @property {object} [skeleton] 加载中提示，对滚动加载模式有效
     * @property {boolean} [fit] 适配父容器，虚拟列表默认自动要设置true
     * @property {number} [itemHeight] 列表项高度，虚拟列表必须要设置
     *
     */
    props: {
      // 数据
      data: {
        type: Array,
        default() {
          return []
        }
      },
      // 加载数据回调函数
      loader: {
        type: Function
      },
      // 显示列数，支持响应式
      columns: {
        type: [Number, Object],
        default: 1
      },
      // 修正不够一行的列， columns > 1 才有效
      fixColumns: Boolean,
      // 显示边框
      border: Boolean,
      // 显示分隔线
      split: Boolean,
      // 斑马条纹
      stripe: Boolean,
      // 尺寸
      size: {
        type: String,
        default: '',
        validator(val) {
          return ['large', 'small', 'mini', ''].includes(val)
        }
      },
      // 头部样式
      headerStyle: Object,
      // 底部样式
      footerStyle: Object,

      // loading配置
      spin: {
        type: Object,
        default() {
          return {
            tip: '正在拼命加载...',
            size: 'large'
          }
        }
      },

      // 显示 加载中
      loading: Boolean,

      // 模式：页码分页、滚动分页、虚拟列表
      mode: {
        type: String,
        default: 'pager',
        validator(val) {
          return ['pager', 'scroll', 'virtual'].includes(val)
        }
      },

      // 初始页码, 从1开始
      page: {
        type: Number,
        default: 1
      },

      // 每页显示几条
      pageSize: {
        type: Number,
        default: 10
      },

      // 记录数
      total: {
        type: Number,
        default: 0
      },

      // 分页其他配置, 如 layout, background, small
      pagination: {
        type: Object,
        default() {
          return {}
        }
      },
      // 初始化完成后调用loader
      auto: {
        type: Boolean,
        default: true
      },
      // 请求错误时显示
      error: {
        type: Boolean
      },
      // 节流时延，单位为ms
      scrollDelay: {
        type: Number,
        default: 200
      },
      // 触发加载的距离阈值，单位为px
      scrollDistance: {
        type: Number,
        default: 0
      },
      // 加载提示
      skeleton: {
        type: Object,
        default() {
          return {
            active: true,
            title: true,
            paragraph: {
              rows: 1,
              width: '100%'
            }
          }
        }
      },
      // 适配父容器，默认自动要设置true
      fit: Boolean,

      // 列表项高度，虚拟列表必须要设置
      itemHeight: Number
    },
    data() {
      return {
        list: [],
        currentPage: this.page,
        currentTotal: this.total,
        currentPageSize: this.pageSize,
        currentLoading: false,
        errorMessage: null
      }
    },
    computed: {
      pageCount() {
        return Math.ceil(this.currentTotal / this.currentPageSize)
      }
    },
    watch: {
      // 初始化数据
      data: {
        immediate: true,
        handler(val) {
          this.list = Object.freeze(val.slice(0))
        }
      },

      list() {
        // 列表变化后，滚动条重置，只对 virtual 模式处理
        if (!this.isVirtual) return
        this.$nextTick(() => {
          this.scrollTop()
        })
      },
      pagerProps: {
        immediate: true,
        handler(props) {
          this.currentPage = props.currentPage
          this.currentTotal = props.total
          this.currentPageSize = props.pageSize
          this.auto &amp;&amp; this.$nextTick(this.load)
        }
      }
    },
    methods: {
      /**
       * 调用loader加载数据
       * @method load
       */
      load() {
        if (!this.loader) return

        const loadedMap = {
          pager: this.pagerLoaded,
          scroll: this.scrollLoaded,
          virtual: this.virtualLoaded
        }

        this.currentLoading = true
        this.errorMessage = null
        this.loader(this.currentPage, this.currentPageSize).then(res => {
          const loaded = loadedMap[this.mode]
          loaded &amp;&amp; loaded(res)
          this.currentTotal = res.total || 0
          /**
           * 请求成功时触发
           * @event success
           * @param {object} [res] 请求响应数据
           */
          this.$emit('success', res)
        }).catch(e => {
          this.errorMessage = e;
          /**
           * 请求失败时触发
           * @event error
           * @param {*} e 错误信息
           */
          this.$emit('error', e)
        }).finally(() => {
          this.currentLoading = false
        })
      },
      /**
       * 刷新列表
       * @method refresh
       * @param {number} [page=1] 刷新的页码
       */
      refresh(page) {
        this.currentPage = page || this.currentPage
        this.load()
      },
      /**
       * 滚到到顶部，fit=true 或 mode=virtual时有效
       * @method scrollTop
       */
      scrollTop(val = 0) {
        if (this.$refs.viewport) {
          this.$refs.viewport.scrollTop = val
        }
      },
      /**
       * 重置滚动条，当元素隐藏后再显示，滚动条位置会丢失，可以调用该方法重置
       * @method reset
       */
      reset() {
        this.scrollTop(this.startOffset)
      }
    }
  }
&lt;/script>
</code></pre>
        </article>
    </section>





    
</div>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.4</a> on Wed Jun 10 2020 17:09:13 GMT+0800 (GMT+08:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>




<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?c4e5f73318b5cb0c389e3d9a05f831cc";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script>

</body>
</html>
